
		
var code;
		
function showCode(str) {
	if (!code) code = $("#code");
	code.empty();
	code.append("<li>"+str+"</li>");
}

function update(){

	var orgName =$("#name").val();
	var orgNon =$("#address").val();
	if(orgName.length==0 || trim(orgName).length == 0){
		layer.alert("机构名称不能为空！");
		window.orgAdmin.document.getElementById("name").focus();
		return;
	}
	//验证只包含字母或者汉字
	var pattern =/(^[\u4e00-\u9fa5A-Za-z0-9_-]*$)/;
	//验证不能为纯数字
	var patternNum=/^\d+$/;
	if (!pattern.test(orgName)) {
		layer.alert("请输入合法的机构名称！");
		return false;
	}
	if (patternNum.test(orgName)) {
		layer.alert("机构名称不能为纯数字！");
		return false;
	}

	if(orgNon.length==0 || trim(orgNon).length == 0){
		layer.alert("地址不能为空");
		return false;
	}



    $("#form-resource").ajaxSubmit({
		dataType : 'html',
        success: function(message){
        		if(message == "200"){
                    layer.msg('操作成功!',{icon:1,time:1000},function(){
/*                         var index = parent.layer.getFrameIndex(window.name);
                        parent.query_brand_form.submit();
                        parent.layer.close(index); */
                        parent.window.location.reload();
                    });
 				}else if(message == "500"){
 					layer.alert("系统繁忙！");
 				}else{
 					layer.alert(message);
 				}
        },
        error: function(){
            layer.msg('操作失败!',{icon:5,time:1000});
        }
    });
}

function save(){
	var content = CKEDITOR.instances.content.getData();
	 $("#content").val(content);
	var orgName =$("#name").val();
	var orgNon =$("#address").val();
	if(orgName.length==0 || trim(orgName).length == 0){
		layer.alert("机构名称不能为空！");
		window.orgAdmin.document.getElementById("name").focus();
		return;
	}
	//验证只包含字母或者汉字
	var pattern =/(^[\u4e00-\u9fa5A-Za-z0-9_-]*$)/;
	//验证不能为纯数字
	var patternNum=/^\d+$/;
	if (!pattern.test(orgName)) {
		layer.alert("请输入合法的机构名称！");
		return false;
	}
	if (patternNum.test(orgName)) {
		layer.alert("机构名称不能为纯数字！");
		return false;
	}

	
    $("#form-resource").ajaxSubmit({
    	
		dataType : 'html',
        success: function(message){
        		if(message == "200"){
                    layer.msg('操作成功!',{icon:1,time:1000},function(){
/*                         var index = parent.layer.getFrameIndex(window.name);
                        parent.query_brand_form.submit();
                        parent.layer.close(index); */
                        parent.window.location.reload();
                    });
 				}else if(message == "500"){
 					layer.alert("系统繁忙！");
 				}else{
 					layer.alert(message);
 				}
        },
        error: function(){
            layer.msg('操作失败!',{icon:5,time:1000});
        }
    });
}
function modify(){
	var content = CKEDITOR.instances.content.getData();
	 $("#content").val(content);
	var orgName =$("#name").val();
	var orgNon =$("#address").val();
	if(orgName.length==0 || trim(orgName).length == 0){
		layer.alert("机构名称不能为空！");
		window.orgAdmin.document.getElementById("name").focus();
		return;
	}
	//验证只包含字母或者汉字
	var pattern =/(^[\u4e00-\u9fa5A-Za-z0-9_-]*$)/;
	//验证不能为纯数字
	var patternNum=/^\d+$/;
	if (!pattern.test(orgName)) {
		layer.alert("请输入合法的机构名称！");
		return false;
	}
	if (patternNum.test(orgName)) {
		layer.alert("机构名称不能为纯数字！");
		return false;
	}


    $("#form-resource").ajaxSubmit({
		dataType : 'html',
        success: function(message){
        		if(message == "200"){
                    layer.msg('操作成功!',{icon:1,time:1000},function(){
/*                         var index = parent.layer.getFrameIndex(window.name);
                        parent.query_brand_form.submit();
                        parent.layer.close(index); */
                        parent.window.location.reload();
                    });
 				}else if(message == "500"){
 					layer.alert("系统繁忙！");
 				}else{
 					layer.alert(message);
 				}
        },
        error: function(){
            layer.msg('操作失败!',{icon:5,time:1000});
        }
    });
}
function trim(str){ 
	 return str.replace(/(^\s*)|(\s*$)/g, "");
	}